<?php
include('rootlogin.php');

mysql_query("SET NAMES 'utf8'");

if(!isset($_POST['topic'])){
			$flag=0;
}
else if($_POST['topic'] == '' ||  $_POST['topic'] == ' '){
			$flag=1;	
}
else{
	$class=$_POST['class'];
	$t = str_replace("'", "&#39;", $_POST['topic']);
	$t = str_replace('"', '&quot;', $t);
	$query = "INSERT INTO topic (name) VALUES ('".$t."')";
	$result = mysql_query($query,$orcp_con) or die('<font color="#C11B17">Error. Please go back to the previous page and try again.</font>');	
	$query = "SELECT topicid FROM topic WHERE name='".$_POST['topic']."' ORDER BY topicid DESC";
	$result = mysql_query($query,$orcp_con);
	$row = mysql_fetch_array($result);	
	$_SESSION['topicid']=$row['topicid'];
	$_SESSION['admin_level']=1;//1 is easy
	header ("location: abstract.php");
}
?>
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="framestyle.css" type="text/css" media="screen">
<style type="text/css">

</style>

</head>
<body>
<div id="wrapper">
<div id="title">Online Listening Comprehension Program</div>

<div id="main">

<form method = POST action="topic.php" >

<hr/>
<div id="title2">ADD A NEW TOPIC</div>
<hr/>
<br><br>
<?php
	if($flag==1){
		echo "<div id='error'>Please fill in all the column.</div><br>";
	}
?>
topic name: 
<input class="area" type="text" name="topic"><br><br>

<br>
<div class="btn_right"><input type="submit" name = "next" value = "next"></div>
</form>

</div>
</div>
</body>

